<?php
/*
* index.eve.php
* 
* Creado por udomos el 13 de diciembre del 2010.
* Última modificación por udomos el 15 de diciembre del 2010.
* Derechos Reservados a Udomos S.A. de C.V. 2010.
*/

// load config file
require_once ($_SERVER["DOCUMENT_ROOT"] . '/config/config.php');
// load date functions file
require_once ($_SERVER["DOCUMENT_ROOT"] . '/modules/functions/date_functions.php');

/*=====	BASE DE DATOS	=====*/

$mdb2 =& MDB2::connect($dsn, $opt);

if (PEAR::isError($mdb2))
	die('Could not connect: '. $mdb2->getMessage());
else{ 
	$WCAT = "";
	$WDAT = "";
	$eveSearch = "";
	
	if(isset($_POST['eve-search'])) {
	$eveSearch = strtolower($_POST['eve-search']);
	}
	if(isset($_POST['eve-cat'])){
		if($_POST['eve-cat'] > 0) $WCAT = " AND(eve_id_category =".$_POST['eve-cat'].")";}
		
	if(isset($_POST['eve-dat'])){
		if($_POST['eve-dat']!=""){
			$eveDatI = substr($_POST['eve-dat'],0,10);
			$eveDatE = substr($_POST['eve-dat'],12,22);
			if($eveDatE == ""){$eveDatE = date('Y-m-d',strtotime($eveDatI)+(3600*24));}
			$WDAT = " AND (eve_dateIni BETWEEN '$eveDatI' AND '$eveDatE'
					    OR eve_dateEnd BETWEEN '$eveDatI' AND '$eveDatE')";
		}
	}
	

	$FROM = "FROM events
						JOIN location ON loc_IDlocation = eve_id_location
						JOIN currencyAd ON ca_IDcurrency = eve_id_currency
						JOIN eventCategory ON ec_IDcategory = eve_id_category
						WHERE LOWER(CONCAT(eve_title,' ',eve_description,' ',ec_description,' ',loc_name)) LIKE '%".$eveSearch."%'
						$WCAT $WDAT";
	
	$counter = _SF("SELECT COUNT(eve_IDevent) AS counter $FROM","counter"); 
}
	$counter = $counter/$_TEL;
	if(!is_int($counter)) $counter = ceil($counter);
		 echo "<ul id='mycarousel' ";
		 if($counter >=15) echo "class='jcarousel-skin-tango'>"; else echo ">";
		 if($counter > 0){
			 for($i=1;$i<=$counter;$i++){	 
				echo "<li><span title='$i' class='";
				if($i == 1) echo "disabled-paginator"; else echo "enable-paginator";
				echo "'>$i</span></li>"; 	
			 }
		 }
		 echo "</ul>";
	 
	 
?>	
<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery('#mycarousel').jcarousel({
			wrap		:'both',
			visible		:15,
			scroll		:15,
		});
	});
</script>